package com.tiancheng.trade.payment.enums;

import com.tiancheng.trade.commom.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: likailun
 * @Description: 二维码交易-附加处理
 * @Date: create in 2021/10/1 10:32
 */
@Getter
@AllArgsConstructor
public enum QrAddnStatusEnum implements BaseEnum<Integer> {
    NONE(0,"无"),
    PASS(1,"附加处理通过"),
    NOT_PASS(2,"附加处理不通过");


    private Integer code;
    private String desc;

    public static String getDesc(Integer code) {
        Optional<QrAddnStatusEnum> found = Arrays.stream(QrAddnStatusEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }

    public static QrAddnStatusEnum getByCode(Integer code){
        Optional<QrAddnStatusEnum> found = Arrays.stream(QrAddnStatusEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        return found.orElse(null);
    }

}
